<template>
	<view>
		<!--个人中心头部开始-->
		<view class="user_head" v-if="init">
			<view class="user_image">
				<image :src="userInfo.avatarUrl"></image>
			</view>
			<view class="user_info">
				<view class="user_name">{{userInfo.nickName}}</view>
				<view class="user_no">编号：{{userInfo.id}}</view>
			</view>
		</view>
		<!--个人中心头部结束-->
		<view class="divLine"></view>
		<!--收藏-->
		<view class="collection">
			<view class="iconfont icon-shoucang" @click="message">
				<view class="text">收藏</view>
			</view>
			<view class="iconfont icon-youce" @click="message" />
		</view>
		<view class="divLine"></view>
		<!--观看历史-->
		<view class="history">
			<view class="iconfont icon-lishi" @click="message">
				<view class="text">历史记录</view>
			</view>
			<view class="iconfont icon-youce" @click="message" />
		</view>
		<view class="divLine"></view>
		<!--设置-->
		<view class="setup">
			<view class="iconfont icon-shezhi" @click="message">
				<view class="text">设置</view>
			</view>
			<view class="iconfont icon-youce" @click="message" />
		</view>
		<view class="divLine"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deviceId: '',
				userInfo: {},
				init: false
			}
		},
		mounted() {
			uni.getStorage({
				key: "deviceId",
				success: res => {
					this.deviceId = res.data
					this.getUserInfo()
				},
				fail: e => {
					this.isLogin = true;
				}
			})
		},
		methods: {
			/**获取当前登录用户信息*/
			getUserInfo() {
				this.request({
					url: this.httpServer + `/v1/app/userInfo/${this.deviceId}`
				}).then(res => {
					console.log(res)
					if (res.code === 200) {
						this.userInfo = res.data
						this.padding(this.userInfo.id);
						this.init = true
					}
				})
			},
			message() {
				uni.showToast({
					title: "该模块暂未开放",
					icon: 'none'
				})
			},
			padding(num) {
				for (var len = (num + "").length; len < 6; len = num.length) {
					num = "0" + num;
				}
				this.userInfo.id = num;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user_head {
		display: flex;
		padding: 10rpx 0rpx;
		align-items: center;

		.user_image {
			flex: 1;
			padding: 20rpx;
			justify-content: center;
			align-items: center;
			display: flex;
			flex-wrap: wrap;

			image {
				border-radius: 50rpx;
				width: 150rpx;
				height: 150rpx;
			}
		}

		.user_info {
			flex: 2;

			.user_name {
				padding: 10rpx;
				display: flex;
				font-size: 40rpx;
				color: #000;
			}

			.user_no {
				font-size: 30rpx;
				color: #8F8F94;
				padding: 10rpx;
			}
		}
	}

	.divLine {
		background: #F1F1F1;
		width: 100%;
		height: 5rpx;
		padding: 5rpx;
	}

	.collection {
		display: flex;
		padding: 10rpx;
		height: 100rpx;
		align-items: center;
		margin-left: 30rpx;
		justify-content: space-between;

		.iconfont {
			display: flex;
			font-size: 40rpx;
			margin-right: 30rpx;

			.text {
				margin-left: 20rpx;
				color: #808080;
				font-size: 30rpx;
			}
		}
	}

	.history {
		display: flex;
		padding: 10rpx;
		justify-content: space-between;
		height: 100rpx;
		align-items: center;
		margin-left: 30rpx;

		.iconfont {
			display: flex;
			font-size: 40rpx;
			margin-right: 30rpx;

			.text {
				margin-left: 20rpx;
				color: #808080;
				font-size: 30rpx;
			}
		}
	}

	.setup {
		display: flex;
		padding: 10rpx;
		justify-content: space-between;
		height: 100rpx;
		align-items: center;
		margin-left: 30rpx;

		.iconfont {
			display: flex;
			font-size: 40rpx;
			margin-right: 30rpx;

			.text {
				margin-left: 20rpx;
				color: #808080;
				font-size: 30rpx;
			}
		}
	}
</style>
